# -*- python -*-

# This code, when invoked by "ovsdb-idlc annotate" (by the build
# process), annotates vswitch.ovsschema with additional data that give
# the ovsdb-idl engine information about the types involved, so that
# it can generate more programmer-friendly data structures.

s["idlPrefix"] = "sbrec_"
s["idlHeader"] = "\"lib/ovn-sb-idl.h\""

s["hDecls"] = '#include "lib/ovn-util.h"'

# Adds an integer column named 'column' to 'table' in 's'.  The column
# values is calculated with 'expression' based on the values of the columns
# named in the array 'dependencies'.
def synthesize_integer_column(s, table, column, dependencies, expression):
    s["tables"][table]["columns"][column] = {
        "type": "integer",
        "extensions": {
            "dependencies": dependencies,
            "parse": "row->%s = %s;" % (column, expression),
            "synthetic": True
        }
    }

synthesize_integer_column(s, "Logical_Flow", "hash",
                          ["logical_datapath", "table_id", "pipeline",
                           "priority", "match", "actions"],
                          "sbrec_logical_flow_hash(row)")
